<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('报销单')" />
    <link rel="stylesheet" href="../../../../../../../../../../../../css/navigation.css">
</head>
<body class="gray-bg">
<div class="navigation visible-xs-block">
    <ol class="breadcrumb">
        <span> > </span>
        <li><a href="#" onclick="gomain()">主页</a></li>
        <li style="color: black">报销列表</li>
    </ol>
    <div class="aLine"></div>
</div>
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>报销类型：</label>
                            <select name="eType" th:with="type=${@dict.getType('expense_eType')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>报销原因：</label>
                            <input type="text" name="eReason"/>
                        </li>
                        <li class="select-time">
                            <label style="width: 100px">报销申请时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginETimeStart]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endETimeStart]"/>
                        </li>
                        <li>
                            <label>报销金额：</label>
                            <input type="text" name="eMoney"/>
                        </li>
                        <li>
                            <label>申请人：</label>
                            <input type="text" name="eTheHeir"/>
                        </li>
<!--                        <li>-->
<!--                            <label>文件上传凭证：</label>-->
<!--                            <input type="text" name="eRemark"/>-->
<!--                        </li>-->
                        <li>
                            <label>报销状态：</label>
                            <select name="eStatus" th:with="type=${@dict.getType('exa_expense_stutas')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
                                </option>
                            </select>
                        </li>
                        <li>
                            <label>审批意见：</label>
                            <input type="text" name="eOpinion"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ruoyi:expense:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ruoyi:expense:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ruoyi:expense:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:expense:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script src="../../../../../../../../../../../../js/breadcrumb.js"></script>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('ruoyi:expense:edit')}]];
    var removeFlag = [[${@permission.hasPermi('ruoyi:expense:remove')}]];
    var prefix = ctx + "ruoyi/expense";
    var eStatus = [[${@dict.getType('exa_expense_stutas')}]];
    var eType = [[${@dict.getType('expense_eType')}]];

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            showColumns: false,
            modalName: "报销列表",
            columns: [{
                checkbox: true
            },
                {
                    field: 'eId',
                    title: '报销单主键',
                    visible: false
                },
                {
                    field: 'eType',
                    title: '报销类型	',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(eType, value);
                    }
                },
                {
                    field: 'eReason',
                    title: '报销原因	'
                },
                {
                    field: 'eTimeStart',
                    title: '报销申请时间'
                },
                {
                    field: 'eMoney',
                    title: '报销金额'
                },
                {
                    field: 'eTheHeir',
                    title: '申请人'
                },
                {
                    field: 'eCreator',
                    title: '创建人'
                },
                {
                    field: 'eDepa',
                    title: '申请人部门'
                },
                {
                    field: 'ePicture',
                    title: '申请人头像',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'eRemark',
                    title: '文件凭证',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return '<a href="javascript:downloadFile(\''+row.eRemark+'\')">下载</a>';
                    }
                },
                {
                    field: 'eStatus',
                    title: '报销状态',
                    align: 'center',
                    formatter: function(value, row, index) {

                        return $.table.selectDictLabel(eStatus, value);
                    }
                },
                {
                    field: 'eOpinion',
                    title: '审批意见'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];

                        if (row.eStatus ==0){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="submitApply(\'' + row.eId+ '\',\'' + row.eType+ '\')"><i class="fa fa-user"></i> 提交</a> ');

                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.eId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.eId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if (row.eStatus ==1){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="revocations(\'' + row.eId + '\')"><i class="fa fa-user"></i> 撤销</a> ');
                        }else if (row.eStatus ==2){

                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="revocations(\'' + row.eId + '\')"><i class="fa fa-user"></i> 撤销</a> ');
                        }else if (row.eStatus ==3){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="over(\'' + row.eId + '\')"><i class="fa fa-user"></i> 结束</a> ');
                        }else if(row.eStatus ==4){
                             actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="submitApply(\'' + row.eId + '\')"><i class="fa fa-user"></i> 重新提交</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.eId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="revocation(\'' + row.eId + '\')"><i class="fa fa-user"></i> 撤销</a> ');
                        }

                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    function downloadFile(eRemark) {
        window.location.href=ctx+"common/download/resource?resource="+eRemark;
    }

    function submitApply(eId,eType) {
        $.modal.confirm("确认要提交申请吗?", function() {
            var url = prefix + "/submitApply";
            var data = { "id": eId,"type":eType };
            $.operate.submit(url, "post", "json", data);
        });
    }
    function over(eId) {

        $.modal.confirm("确认要结束流程吗?", function() {
            var url = prefix + "/over";
            var data = { "id": eId };
            $.operate.submit(url, "post", "json", data);
        });
    }
    function revocations(eId) {

        $.modal.confirm("确认要撤销申请吗?", function () {
            var url = prefix + "/revocation";
            var data = {"id": eId};
            $.operate.submit(url, "post", "json", data);
        });
    }
</script>
</body>
</html>